<?
$p=$_REQUEST["p"]?$_REQUEST["p"]:1;
$news=$newModule->getNews($p,10,"","4");
?>
<div class="col7">
    <h2>Coffee News</h2>
    <br/>
    <div style="<?=$paras["new_height"]?>">
        <?
        $numfirst=0;
        if(count($news)>=4) $numfirst=1;
        if(count($news)>=7) $numfirst=2;
        if(count($news)>=10) $numfirst=3;
        if($news==null){
            echo '
                <div style="padding:0 20px">
                <div id="mini_inner" class="centered">
                <img src="images/icon/48/dialog_warning.png" alt="" height="50" class="alert">
                <h1>Error 502:Oh no! Trang này không có nội dung.</h1>
                <p>Hãy kiểm tra và chắc rằng trang bạn xem có nội dung. Có thể trang này đang được nâng cấp.</p>
                </div>
                </div>
                ';
        }else for( $i=$numfirst;$i<count($news);$i++){
            $new=$news[$i];
            $small_img=null;
            if(!$new["delete"]){

                    if($new["image"]) $small_img=$new["image"];
                    if($new["small_image"]) $small_img=$new["small_image"];
                    $insert = new DateTime($new["insert"]);
                ?>
                <div class="new-item brief" style="position: relative">
                    <?
                    if($small_img){
                    ?>
                    <div class="img-news" style="">
                        <div class="time_block" style="position: absolute;top: 4px;left: 4px;">
                            <?=date_format($insert,"d")?><br>
                            <span><?=date_format($insert,"M")?></span>
                        </div>
                        <img src="<?=$small_img?>"/>
                    </div>
                    <?
                    }else{
                    ?>
                    <div class="time_block left">
                        <?=date_format($insert,"d")?><br>
                        <span><?=date_format($insert,"M")?></span>
                    </div>
                    <?}?>
                    <h4><a href="#!/page_MORE" onclick="loadmore('<?=$new["id"]?>');"><?=$new["title"]?></a></h4>
                    <div class="small-time">Đăng lúc : <?=$new["insert"]?></div>
                    <div style="height: 72px;overflow: hidden">
                        <?=$new["brief"]?>
                    </div>
                    <a href="#!/page_MORE" class="button-more hidden" 
                    onclick="loadmore('<?=$new["id"]?>');"
                    style="position: absolute;bottom: 16px;right: 30px">Chi Tiết</a>
                </div>
                <div class="clear"></div>
        <?

            }
        }
        ?>




    </div>
    <div class="pages" style="text-align: center">
        
        <div class="icon24 spaceright <?=($p==1)?"hover50":""?>" style="display: inline;cursor: pointer"
             onclick="<?=$p>1?"$('.id-new-content').load('Controller/?AUnit=load_new_content&p=".($p-1)."');":""?>"
             >
            <img src="images/icon/24/pre.png"/>
        </div>&nbsp;&nbsp;&nbsp;
        <div class="icon24 " style="display: inline;cursor: pointer"
             onclick="$('.id-new-content').load('Controller/?AUnit=load_new_content&p=<?=($p+1)?>');"
             >
            <img src="images/icon/24/nex.png"/>
        </div>
        
    </div>
</div>
<div class="col8 pad_left5">
    <br/><br/>
    <?

    $small_img=null;
    for( $i=0;$i<$numfirst;$i++){
        $newfirst=$news[$i];
        $insert = new DateTime($newfirst["insert"]);
        if($newfirst["image"]) $small_img=$newfirst["image"];
        if($newfirst["small_image"]) $small_img=$newfirst["small_image"];
    ?>
    <div class="time_block left">
        <?=date_format($insert,"d")?><br>
        <span><?=date_format($insert,"M")?></span>
    </div>
    <h2><a href="#!/page_MORE" class="" 
            onclick="loadmore('<?=$newfirst["id"]?>');"><?=$newfirst["title"]?></a>
    </h2>
    
    <div class="small-time">Đăng lúc : <?=$newfirst["insert"]?></div>
    <? if($small_img): ?>
    <center><img style="" src="<?=$small_img?>"/></center>
    <? endif ?>
    <div>
        <?=$newfirst["brief"]?>
    </div>
    <div class="line2"></div>
    <?
    }
    ?>

</div>
<div class="clear"></div>

